package org.itboys.weixin.entity;
/**
 * 发红包时 需要商户的一些信息
 * @author weisky
 *
 * 2016年4月20日
 */
public class WeixinShopConfig {

	private String nonceStr;//必填  随机字符串 
	private String sign;//必填  签名
	private String mchBillno;//必填  商户订单号
	private String mchId;//必填  商户号
	private String wxappId;//必填  公众账号appid
	private String sendName;//必填  商户名称 
	private String openId;//必填  用户openid 
	private int totalAmount;//必填  付款金额，单位分
	private int totalNum;//必填  红包发放总人数
	private String wishing;//必填  红包祝福语
	private String clientIp;//必填  Ip地址 
	private String actName;//必填  活动名称 
	private String remark;//必填  备注 
	private String key;//商户的API密钥
	
	public String getKey() {
		return key;
	}
	public void setKey(String key) {
		this.key = key;
	}
	public String getNonceStr() {
		return nonceStr;
	}
	public void setNonceStr(String nonceStr) {
		this.nonceStr = nonceStr;
	}
	public String getSign() {
		return sign;
	}
	public void setSign(String sign) {
		this.sign = sign;
	}
	public String getMchBillno() {
		return mchBillno;
	}
	public void setMchBillno(String mchBillno) {
		this.mchBillno = mchBillno;
	}
	public String getMchId() {
		return mchId;
	}
	public void setMchId(String mchId) {
		this.mchId = mchId;
	}
	public String getWxappId() {
		return wxappId;
	}
	public void setWxappId(String wxappId) {
		this.wxappId = wxappId;
	}
	public String getSendName() {
		return sendName;
	}
	public void setSendName(String sendName) {
		this.sendName = sendName;
	}
	public String getOpenId() {
		return openId;
	}
	public void setOpenId(String openId) {
		this.openId = openId;
	}
	public int getTotalAmount() {
		return totalAmount;
	}
	public void setTotalAmount(int totalAmount) {
		this.totalAmount = totalAmount;
	}
	public int getTotalNum() {
		return totalNum;
	}
	public void setTotalNum(int totalNum) {
		this.totalNum = totalNum;
	}
	public String getWishing() {
		return wishing;
	}
	public void setWishing(String wishing) {
		this.wishing = wishing;
	}
	public String getClientIp() {
		return clientIp;
	}
	public void setClientIp(String clientIp) {
		this.clientIp = clientIp;
	}
	public String getActName() {
		return actName;
	}
	public void setActName(String actName) {
		this.actName = actName;
	}
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	
	public String sort(){
		return "act_name="+getActName()+"&client_ip="+getClientIp()
				+ "&mch_billno="+getMchBillno()
				+ "&mch_id="+getMchId()+"&nonce_str="+getNonceStr()
				+ "&re_openid="+getOpenId()+"&remark="+getRemark()
				+ "&send_name="+getSendName()+"&total_amount="+getTotalAmount()+"&total_num="+getTotalNum()
				+ "&wishing="+getWishing()+"&wxappid="+getWxappId()
				+ "&key="+getKey();
	}
	
	/**
	 * 转xml
	 * @return
	 */
	public String toXml(){
		String xml = "<xml>\n"+
				     "<sign><![CDATA["+getSign()+"]]></sign>\n" +
				     "<mch_billno><![CDATA["+getMchBillno()+"]]></mch_billno>\n"+
				     "<mch_id><![CDATA["+getMchId()+"]]></mch_id>\n"+
				     "<wxappid><![CDATA["+getWxappId()+"]]></wxappid>\n"+
					 "<send_name><![CDATA["+getSendName()+"]]></send_name>\n"+
					 "<re_openid><![CDATA["+getOpenId()+"]]></re_openid>\n"+
					 "<total_amount><![CDATA["+getTotalAmount()+"]]></total_amount>\n"+
					 "<total_num><![CDATA["+getTotalNum()+"]]></total_num>\n"+
					 "<wishing><![CDATA["+getWishing()+"]]></wishing>\n"+
					 "<client_ip><![CDATA["+getClientIp()+"]]></client_ip>\n"+
					 "<act_name><![CDATA["+getActName()+"]]></act_name>\n"+
					 "<remark><![CDATA["+getRemark()+"]]></remark>\n"+
					 "<nonce_str><![CDATA["+getNonceStr()+"]]></nonce_str>\n"+
					 "</xml>\n";
		System.out.println("请求的xml:" + xml);
		
		String xml2 = "<xml>"+
						"<act_name><![CDATA["+getActName()+"]]></act_name>"+
						"<client_ip><![CDATA["+getClientIp()+"]]></client_ip>"+
						"<mch_billno><![CDATA["+getMchBillno()+"]]></mch_billno>"+
						"<mch_id><![CDATA["+getMchId()+"]]></mch_id>"+
						"<nonce_str><![CDATA["+getNonceStr()+"]]></nonce_str>"+
						"<re_openid><![CDATA["+getOpenId()+"]]></re_openid>"+
						"<remark><![CDATA["+getRemark()+"]]></remark>"+
						"<send_name><![CDATA["+getSendName()+"]]></send_name>"+
						"<total_amount><![CDATA["+getTotalAmount()+"]]></total_amount>"+
						"<total_num><![CDATA["+getTotalNum()+"]]></total_num>"+
						"<wishing><![CDATA["+getWishing()+"]]></wishing>"+
						"<wxappid><![CDATA["+getWxappId()+"]]></wxappid>"+
						"<sign><![CDATA["+getSign()+"]]></sign>"+
					"</xml>";
		
		return xml2;
	}
	
}
